package PCClient2;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;


public class ClientMainThread {
    public static void main(String[] args) throws IOException {
        Thread manage_thread = new Thread(new ManageThread());
        manage_thread.start();
        Thread send_thread = new Thread(new SendThread());
        send_thread.start();

        DatagramSocket socket_listen = new DatagramSocket(ShareSpaceAndFun.myPort);
        DatagramPacket packet_listen = null;
        byte[] data = null;
        System.out.println("***客户端2启动，等待接收数据***");
        while(true){
            data = new byte[1024];//创建字节数组，指定接收的数据包的大小
            packet_listen = new DatagramPacket(data, data.length);
            socket_listen.receive(packet_listen);//此方法在接收到数据报之前会一直阻塞
            Thread thread = new Thread(new ListenThread(socket_listen, packet_listen));
            thread.start();
        }
    }
}